//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.liy.cloud.auth.client.aop;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AuthorizationInterceptorConfig implements WebMvcConfigurer {
    private static Logger log = LoggerFactory.getLogger(AuthorizationInterceptorConfig.class);
    @Value("${dascloud.authrization.enabled: true}")
    private Boolean enabled;
    @Value("${dascloud.authrization.patterens: /**}")
    private String patterns;
    @Value("${dascloud.authrization.excludePatterns: /info,/api/*,/error*}")
    private String excludePatterns = "";
    @Autowired
    private AuthorizationInterceptorService serviceAuthorizationInterceptor;

    public AuthorizationInterceptorConfig() {
    }

    public void addInterceptors(InterceptorRegistry registry) {
        if (this.enabled) {
            log.info("Added Authentication Interceptor Successfully.");
            InterceptorRegistration interceptorRegistration = registry.addInterceptor(this.serviceAuthorizationInterceptor);
            String[] patternArr = this.patterns.split(",");
            interceptorRegistration.addPathPatterns(patternArr);
            String[] excludePatternArr = this.excludePatterns.split(",");
            interceptorRegistration.excludePathPatterns(excludePatternArr);
           // super.addInterceptors(registry);
        }
    }
}
